package com.ruoyi.celoan.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.celoan.dto.EcDalianDataReportStatisticsDto;
import com.ruoyi.celoan.entity.DalianDataReportKeyEntity;
import com.ruoyi.celoan.entity.EcDalianDataReportStatisticsEntity;
import com.ruoyi.celoan.mapper.EcDalianDataReportStatisticsMapper;
import com.ruoyi.celoan.service.IEcDalianDataReportKeyService;
import com.ruoyi.celoan.service.IEcDalianDataReportLogsService;
import com.ruoyi.celoan.service.IEcDalianDataReportStatisticsService;
import com.ruoyi.celoan.util.DataReportUtil;
import com.xmsme.base.sdk.BaseApiClient;
import com.xmsme.base.sdk.response.StatisticsPostResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EcDalianDataReportStatisticsServiceImpl
        extends ServiceImpl<EcDalianDataReportStatisticsMapper, EcDalianDataReportStatisticsEntity>
        implements IEcDalianDataReportStatisticsService {
    private static final Logger log = LoggerFactory.getLogger(EcDalianDataReportStatisticsServiceImpl.class);
    @Autowired
    private IEcDalianDataReportLogsService dalianDataReportLogsService;
    @Autowired
    private IEcDalianDataReportKeyService keyService;

    public void getDataReport(BaseApiClient client, DalianDataReportKeyEntity entity) {
        EcDalianDataReportStatisticsDto dataReportStatisticsDto = ((EcDalianDataReportStatisticsMapper) this.baseMapper).getDataReport();
        dataReportStatisticsDto.setRegisterEntNum(Integer.valueOf(53406));
        try {
            this.dalianDataReportLogsService.addLogs("融资统计数据回传接口请求数据", JSONObject.toJSONString(dataReportStatisticsDto));
            StatisticsPostResponse response = DataReportUtil.dataReport(dataReportStatisticsDto, client);
            this.dalianDataReportLogsService.addLogs("融资统计数据回传接口返回结果数据", JSONObject.toJSONString(response));
            log.info("数据上报成功");
        } catch (Exception e) {
            e.printStackTrace();
            log.info("数据上报异常:" + e.getMessage());
        }
    }

    public void updatePassword(BaseApiClient client, DalianDataReportKeyEntity entity) throws Exception {
        String appSecret = DataReportUtil.userUpdate(client, entity.getAppId(), entity.getAppKey(), entity.getAppSecret());
        entity.setAppSecret(appSecret);
        this.keyService.updateEntity(entity);
        log.info("更新用户密码完成；" + JSONObject.toJSONString(appSecret));
    }
}


/* Location:              D:\tuodayun\workspace\work\celoan-third-data-report-service-2.0.0-SNAPSHOT.jar!\BOOT-INF\classes\com\celoan\service\impl\EcDalianDataReportStatisticsServiceImpl.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */
